﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Stardust.Common.Utils
{
    public static class SerializerHelper
    {
        public static T DeserializeFromString<T>(string json)
        {
            return ServiceStack.Text.JsonSerializer.DeserializeFromString<T>(json);
        }

        public static object DeserializeFromString(string json, Type objType)
        {
            return ServiceStack.Text.JsonSerializer.DeserializeFromString(json, objType);
        }

        public static void SerializeToStream(object obj, Type objType, Stream stream)
        {
            ServiceStack.Text.JsonSerializer.SerializeToStream(obj, obj.GetType(), stream);
        }
        public static string SerializeToString(object obj)
        {
            return ServiceStack.Text.JsonSerializer.SerializeToString(obj, obj.GetType());
        }
    }
}
